<?php
namespace Admin\Model;
use Think\Model;
class AdministratorModel extends Model {
	//校验用户名和密码
	public function checkUser($name,$pwd) {
		$data = $this->field('AdministratorId,AdministratorName,Password')->where(array('AdministratorId'=>$name))->find();
		if($data===null){
			return '用户名不存在';
		}
		if($data['Password']==$this->password($pwd)){
			//密码正确
			session('admin_id',$name);
			session('admin_name',$data['AdministratorName']);
			return true;
		}
		return '密码错误';
	}
	//密码加密函数
	public function password($pwd){
		return  substr(md5(sha1(md5($pwd).'fe').'f342g').'lbf',2,47);
	}
}
